<%@page import="Data.Subcriber"%>
<%@page import="Data.Member"%>
<%@page import="java.util.ArrayList"%>
<%@page import="Data.Category"%>
<section id="content" class="gray-area">
    <div class="container car-detail-page">
        <div class="row">
            <div id="main" class="col-md-9">
                <div class="tab-container">
                    <ul class="tabs">
                        <li class="active">
                            <a  data-toggle="tab">Subcriber</a>
                        </li>
                    </ul>
                    <div class="tab-content">
                        <div style="min-height: 500px; font-size: 16px; " class="tab-pane fade in active" id="car-details">
                            <form action="../SubcriberPR" method="post" name="frmSub">
                                <%

                                    if (session.getAttribute("ssusercl") != null) {
                                        String user = (String) session.getAttribute("ssusercl");
                                        if (user == "") {
                                            // out.print("<td><a style='text-decoration: underline; color:#00A8FF;' href='index.jsp?page=Login'>Click here to Login</a></td>");
                                        } else {
                                            out.print("You select the event you wish to receive mail! <br/>");
                                            String str = "";
                                            Category cate;
                                            Member mem = new Member();
                                            ArrayList<Member> pm = mem.MselectByquery("SELECT * FROM Member where Username='" + user + "'");
                                            if (pm.size() > 0) {
                                                for (int im = 0; im < pm.size(); im++) {
                                                    Member paym = pm.get(im);
                                                    out.print("<input type='hidden' name='txtMemEnroll' id='txtMemEnroll' value='" + paym.getMemberID() + "' />");
                                                    //
                                                    Category ct = new Category();
                                                    ArrayList<Category> a = ct.CselectbyQuery(" AND Status=1");
                                                    if (a.size() > 0) {
                                                        for (int i = 0; i < a.size(); i++) {
                                                            cate = a.get(i);
                                                            //
                                                            Subcriber sub = new Subcriber();
                                                            ArrayList<Subcriber> ASbub = sub.SselectbyMemID(paym.getMemberID());
                                                            if (ASbub.size() > 0) {
                                                                for (int is = 0; is < ASbub.size(); is++) {
                                                                    Subcriber lssub = ASbub.get(is);
                                                                    //
                                                                    if (lssub.getCategoryID() == cate.getCategoryID()) {
                                                                        str += "<input type='radio' name='checksub' id='checksub' checked='checked' value='" + cate.getCategoryID() + "' />&nbsp;&nbsp;" + cate.getCategoryName() + "<br/>";
                                                                    } else {
                                                                        str += "<input type='radio' name='checksub' id='checksub' value='" + cate.getCategoryID() + "' />&nbsp;&nbsp;" + cate.getCategoryName() + "<br/>";
                                                                    }
                                                                }
                                                            } else {
                                                                str += "<input type='radio' name='checksub' id='checksub' value='" + cate.getCategoryID() + "' />&nbsp;&nbsp;" + cate.getCategoryName() + "<br/>";
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                            out.print(str);
                                            out.print(" <input type='submit'  style='background:  #00A8FF; border: none; width: 120px; height: 40px; color: #fff;' name='btnSubcriber' id='btnSubcriber' value='Subcriber' />");
                                        }
                                    } else {
                                        out.print("<div style='font-size:18px;text-align:center;'>Please <a style='text-decoration: underline; color: #00A8FF' href='index.jsp?page=Login'>login</a> to subscribe to newsletters </div>");
                                        //out.print("<input type='checkbox' name='checksub' id='checksub' value='" + cate.getCategoryID() + "' />&nbsp;&nbsp;" + cate.getCategoryName() + "<br/>");
                                    }



                                %>

                            </form>
                        </div>
                    </div>
                </div>
            </div>

            <jsp:include page="menu-right.jsp" />
        </div>
    </div>
</section>